package mBeanControl.interfacesImpl;

import javax.management.MBeanServerConnection;
import javax.management.ObjectName;

import mBeanControl.interfaces.IJVMRuntime;

public class JVMRuntime implements IJVMRuntime{
	private MBeanServerConnection connection;
	private ObjectName jVMRuntimeMBean;
	
	public JVMRuntime(MBeanServerConnection connection, ObjectName runtimeMBean) {
		this.connection = connection;
		this.jVMRuntimeMBean = runtimeMBean;
	}
	
	public Long getHeapSizeCurrent(){
		try {
			return (Long) connection.getAttribute(jVMRuntimeMBean, "HeapSizeCurrent");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
}
